import { ElMessage, ElMessageBox } from 'element-plus'

export default {
  success(message) {
    ElMessage({
      message,
      type: 'success',
    })
  },
  error(message) {
    ElMessage({
      message,
      type: 'error',
    })
  },
  confirm(option) {
    return new Promise((resolve, reject) => {
      let { content, type, title } = option
      ElMessageBox.confirm(content, title,
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type,
        }
      ).then(() => {
        resolve()
      })
      .catch(() => {
        reject()
      })
    })
  }
}
